package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Business;
import cn.wolfcode.mapper.BusinessMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IBusinessService;
import cn.wolfcode.util.FileUploadUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletContext;
import java.io.File;
import java.util.List;

@Service
public class BusinessServiceImpl implements IBusinessService {

    @Autowired
    private BusinessMapper businessMapper;


    public void setBusinessMapper(BusinessMapper businessMapper) {
        this.businessMapper = businessMapper;
    }

    public void deleteByPrimaryKey(Long id) {
        businessMapper.deleteByPrimaryKey(id);
    }

    public void insert(Business record) {
        businessMapper.insert(record);
    }


    public Business selectByPrimaryKey(Long id) {
        Business business = businessMapper.selectByPrimaryKey(id);
        return business;
    }

    public List<Business> selectAll() {
        List<Business> businesss = businessMapper.selectAll();
        return businesss;
    }

    @Override
    public void updateByPrimaryKey(Business record) {
        businessMapper.updateByPrimaryKey(record);
    }


    //分页查询
    public PageInfo<Business> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), "open_date desc");
        List<Business> businesss = businessMapper.selectForList(qo);
        return new PageInfo<>(businesss);
    }


}
